#!/bin/sh
#
# This script adapts output of scanelf to the format produced by
# GNU's "ldconfig -p".
#
# Note: Julia uses "ldconfig -p" as a workaround to find system
# libraries, see https://github.com/JuliaLang/julia/issues/6742.
#
set -e

echo 'libs found on ldpath'
scanelf --ldpath -E ET_DYN -BF '%F %M %S %f' | while read path class soname _; do
	case "$class" in
		ELFCLASS32) arch='i686';;
		ELFCLASS64) arch='x86-64';;
		*) arch="$(uname -m | sed 's/_/-/g')";;
	esac
	printf '\t%s (libc,%s) => %s\n' "$soname" "$arch" "$path"
done
